import java.util.Scanner;
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Test3 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String s1 = in.nextLine();
            String s2 = in.nextLine();
            HashSet<Character> set = new HashSet<>();
            for(int i =0;i<s2.length();i++){
                if(!s1.contains(String.valueOf(s2.charAt(i)))){
                    System.out.println("No");
                    return;
                }
            }
            char[] c1 = s1.toCharArray();
            char[] c2 = s2.toCharArray();
         HashMap<Character,Integer> map1 = new HashMap<>();
         HashMap<Character,Integer> map2 = new HashMap<>();
         for(int i=0;i<c1.length;i++){
             map1.put(c1[i],0);
         }
         for(int i =0;i<c1.length;i++){
             int value = map1.get(c1[i]);
             value++;
             map1.put(c1[i],value);

         }
            for(int i=0;i<c2.length;i++){
                map2.put(c2[i],0);
            }
            for(int i =0;i<c2.length;i++){
                int value = map2.get(c2[i]);
                value++;
                map2.put(c2[i],value);
            }
            for(int i =0;i<c2.length;i++){
                if(map2.get(c2[i])!=map1.get(c2[i])){
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
        }
    }
}